// pages/user/user/userSetting/userSetting.js
import Api from '../../../../utils/http';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: null, //个人信息
    mobile: null, //电话号码
  },
  //跳转绑定手机号
  toChangeBindTel: function () {
    wx.navigateTo({
      url: '/pages/user/user/bindTelStepOne/bindTelStepOne',
    })
  },
  //跳转身份验证
  toIdentityAuth: function () {
    if (this.data.userInfo.verification_depart==1) {
      wx.showToast({
        title: '已认证',
        icon:'none',
        duration:1000
      })
    }else{
      wx.navigateTo({
        url: '/pages/user/user/identityAuth/identityAuth',
      })
    }
    
  },
  //跳转身份二维码
  Qrcode: function () {
    var that = this;
    wx.navigateTo({
      url: '/pages/user/user/userCode/userCode?codeType=1',
    })
  },
  //跳转变更部门负责人
  personCharge: function () {
    var that = this;
    wx.navigateTo({
      url: '/pages/recycling/changeExplain/changeExplain',
    })
  },
  // //退出
  // logoutWxApp: function(){

  // },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getusertext();
  },
  //个人信息详情
  getusertext: function () {
    var that = this;
    let uid = wx.getStorageSync('userid');
    var param = {
      uid: uid.id,
      user_type: uid.user_type,
    };
    console.log(param)
    Api.ajax("/app/Zpersonalcenter/userInfo", param).then(res => {
      console.log(res)
      if (res.code == 200) {
        wx.setStorageSync('userid', res.data);
        that.setData({
          userInfo: res.data,
          mobile: res.data.mobile
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})